<template>
	<view>
		<u-navbar
			:is-back="false"
			:background="{
				backgroundColor: '#fff'
			}"
		>
			<u-avatar class="avatar-x" sex-icon="woman" show-sex show-level :src="userInfo.avatar_file.url" mode="circle" @click="handleAvatarClick"></u-avatar>
			<u-search class="search-x" shape="round" placeholder=" " :show-action="false" @focus="searchFocus"></u-search>
		</u-navbar>
		<!-- 内容 -->
		<lg-tabs-swiper  type="issue" :request="pageDemand" :swipterList="[{ name: '江湖' }, { name: '帮派' }]"></lg-tabs-swiper>
		<!-- 悬浮按钮 -->
		<view class="suspend-btn-x">
			<u-button plain ripple :custom-style="customStyle" type="primary" shape="circle" @click="clickEdit">
				<u-icon name="edit-pen" color="#2979ff" size="50"></u-icon>
			</u-button>
		</view>
		<!-- 底部导航栏 -->
		<u-tabbar :list="tabbar" :mid-button="true"></u-tabbar>
	</view>
</template>

<script>
import { mapGetters, mapMutations } from 'vuex';
import { pageDynamicByType } from '../../services/home/index.js';
export default {
	data() {
		return {
			tabbar: [],
			avaterSrc: '',
			request: pageDynamicByType
		};
	},
	computed: {
		...mapGetters({
			userInfo: 'user/info',
			hasLogin: 'user/hasLogin'
		}),
		customStyle() {
			return {};
		}
	},
	methods: {
		async pageDemand({ id = '' }) {
				let where = { _id: this.$dbCmd.gt(id) }
				if (!id) {
					where = {}
				}
			const result =  await this.$db
					.collection('lg-demand')
					.where(where)
					.limit(6)
					.get()
			 return  Promise.resolve(result)	   
		},
		searchFocus() {},
		async clickEdit() {
			// console.log(this.userInfo);
			// return;
			console.log( await  this.pageDemand({}));
			this.$u.route('pages/redactor/redactor');
			
		 //  const res =	await this.$db.collection("lg-demand").where({
			//   _id: this.$dbCmd.neq(null)
			// }).remove()
			
			// console.log(res);
		}
	},
	onLoad(v) {},
	onShow() {
		this.tabbar = getApp().globalData.tabbar;
		uni.$on('redactor-update-html', function(data) {
			console.log('监听到事件来自 update ，携带参数 msg 为：' + data.html);
		});
	}
};
</script>

<style lang="scss" scoped>
.suspend-btn-x {
	position: fixed;
	bottom: 150rpx;
	right: 50rpx;
}
.avatar-x {
	margin: 0 25rpx;
}

.search-x {
	margin-left: 20rpx;
	margin-bottom: 10rpx;
}
</style>
